import {
  ApiProperty
} from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { ApiRes } from '.';

export enum RepairsStatus {
  //已取消
  Cancle = 0,
  //受理中
  Processing = 1,
  //上门中
  UnderWay = 2,
  //已完成
  finshed = 3,
}

export class RepairId {
  @ApiProperty({ description: '报修id', required: true })
  @Rule(RuleType.number().required().error(new Error('报修id不能为空')))
  id: number;
}

export class RepairAddItem {
  @ApiProperty({ description: '问题描述', required: true })
  @Rule(RuleType.string().required().error(new Error('问题描述不能为空')))
  description: string;

  @ApiProperty({ description: '预约上门时间', required: true })
  @Rule(RuleType.string().required().error(new Error('预约上门时间不能为空')))
  appointment: string;

  @ApiProperty({ description: '联系电话', required: true })
  @Rule(RuleType.number().required().error(new Error('联系电话不能为空')))
  phone: number;

  @ApiProperty({ description: '报修项id', required: true })
  @Rule(RuleType.number().required().error(new Error('报修项id不能为空')))
  repairItemId: number;

  @ApiProperty({
    description: '附件',
    default:[]
  })
  @Rule(RuleType.array<string>())
  attachment: string[];

  @ApiProperty({ description: '房屋id', required: true })
  @Rule(RuleType.number().required().error(new Error('房屋id不能为空')))
  houseId: number;
}
export class RepairEditItems extends RepairAddItem {
  @ApiProperty({ description: '报修id', required: true })
  @Rule(RuleType.number().required().error(new Error('报修id不能为空')))
  id: number;
}
export class RepairItems extends RepairAddItem {
  @ApiProperty({ description: '报修id', required: true })
  @Rule(RuleType.number().required().error(new Error('报修id不能为空')))
  id: number;

  @ApiProperty({
    description: '报修状态1受理中2上门中0已取消3已完',
    default: RepairsStatus.Processing,
    required: true,
  })
  @Rule(RuleType.number().required().error(new Error('报修状态不能为空')))
  status: number;

  @ApiProperty({ description: '报修项名称', required: true })
  @Rule(RuleType.string().required().error(new Error('名称不能为空')))
  repairItemName: string;

  @ApiProperty({ description: '小区名称', required: true })
  @Rule(RuleType.string().required().error(new Error('小区名称不能为空')))
  pointName: string;

  @ApiProperty({ description: '小区楼栋信息', required: true })
  @Rule(RuleType.string().required().error(new Error('小区楼栋信息不能为空')))
  building: string;

  @ApiProperty({ description: '小区房间信息', required: true })
  @Rule(RuleType.string().required().error(new Error('小区房间信息不能为空')))
  room: string;

  @ApiProperty({ description: '业主姓名', required: true })
  @Rule(RuleType.string().required().error(new Error('业主姓名不能为空')))
  userName: string;
}

export class RepairItemsResDto extends ApiRes<RepairItems>(RepairItems) {}

export class RepairsStatusDto {
  @ApiProperty({
    description: '审核状态1受理中2上门中0已取消3已完成',
    default: RepairsStatus.Processing,
    required: true,
  })
  @Rule(RuleType.string().required().error(new Error('审核状态不能为空')))
  status: string;
}

export class RepairsUpdateDto extends RepairsStatusDto {
  @ApiProperty({ description: '报修id', required: true })
  @Rule(RuleType.number().required().error(new Error('报修id不能为空')))
  id: number;
}
